<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片区域 -->
    <el-card>
      <el-table :data="rightsList" stripe border>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column
        ><el-table-column prop="path" label="路径"></el-table-column
        ><el-table-column prop="level" label="权限等级">
          <template slot-scope="data">
            <el-tag v-if="data.row.level == 0">一级</el-tag>
            <el-tag v-else-if="data.row.level == 1" type="success">二级</el-tag>
            <el-tag v-else type="danger">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      // 权限列表
      rightsList: []
    }
  },
  // 钩子函数:当配置对象成员都挂在到组件实例对象上后执行
  created() {
    // 发送求情所有权限列表接口
    this.getRightsList()
  },
  methods: {
    // 请求权限列表
    async getRightsList() {
      // 请求数据
      const { data: resData } = await this.$http.get('rights/list')
      // 判断数据
      if (resData.meta.status != 200)
        return this.$message.error(resData.meta.msg)
      // 如果成功,则设置resData.data中的权限数组给实例.data
      this.rightsList = resData.data
    }
  }
}
</script>
<style lang="less" scoped></style>
